<template>
    <div class="right">
        <h1>{{msg}}</h1>
    </div>
</template>

<script>
import bus from '@/eventBus'
export default {
  data(){
    return{
        msg:''
    }
  },
  /*
    created的钩子函数，当组件被创建完之后被调用
  */
  created(){
    bus.$on('share',(val)=>{
       this.msg=val
    })
  }
}
</script>

<style>
    .right{
        width: 100vw;
        height: 200px;
        background-color: yellow;
        color: red;
    }
</style>